/**********************************************************************************************/
/* FBL_Types.h 		                                                      					  */
/*                                                                       					  */
/* Copyright Paradigma, 1993-2006															  */
/* All Rights Reserved                                                   					  */
/**********************************************************************************************/

#ifndef _FBL_Types_h 
	#define _FBL_Types_h
#pragma once

#include <VShared/FBL/publ/Headers/FBL_Macros.h>

#if FBL_THREADSAFE
	#include <VShared/FBL/publ/Headers/FBL_Atomic.h>
#endif

/**********************************************************************************************/
FBL_Begin_Namespace



/**********************************************************************************************/
// Useful shortcuts for fundamental C types.
//
typedef unsigned char   		uchar;
typedef unsigned short  		ushort; 
typedef unsigned long   		ulong;

#if defined(_MSC_VER)
	typedef __int64  			llong;
	typedef unsigned __int64    ullong;
#else
	typedef long long  			llong;
	typedef unsigned long long  ullong;
#endif

//typedef long double				ldouble;


/**********************************************************************************************/
// reference counter used in all I_Unknown classes
//
typedef struct RefCount
{
#if FBL_THREADSAFE
	AtomicUInt32				mValue; // aligned
#else
	volatile ulong				mValue;
#endif
	
	RefCount( void ) : mValue(0) {}
	
} RefCount;


/**********************************************************************************************/
// This types specify database parameters: 
//
#if FBL_LENGTH <= 32
	typedef ulong 				flength;	// type for file length < 2GB.
#else 
	typedef ullong 				flength;	// type for file length > 2GB.
#endif
  
  
/**********************************************************************************************/
// REC_ID and OID types.
//
typedef ulong 	REC_ID;		// type for RecID, so up to 4 billions records in one Table.	
 
typedef REC_ID POSITION;	// Cursor does not have rec_id. It always operates
							// with positions.

typedef REC_ID 	ID_TYPE;	// Some algorithms require to work with numbers
							// that must be the same type as REC_ID, but they are not RecIDs
							// of some table, so we specify special type name.

typedef long	Table_ID;	// ID of a Table. Tmp Table have negative ID.

typedef ushort	Field_ID;	// ID of a Field. 

typedef ulong	IndStyle_ID;	// ID of a Index style. 

typedef long	Link_ID;	// ID of a Link. Tmp Link have negative ID.

typedef llong	OID;		// "Object ID" = (Table_ID << 32) | REC_ID

typedef long	View_ID;	// ID of a View

typedef long	Trigger_ID;	// ID of a Trigger

typedef long	StoredProcedure_ID;	// ID of a Stored procedure

typedef ulong 	ERROR_TYPE;


/**********************************************************************************************/
// Types of objects of a KERNEL which the user may develop and use as statically linked or
// dynamically loaded (as Plugins) libraries. This is why they are declared as typedef 
// but not as enums.
//
typedef ulong 	VALUE_TYPE;					
typedef ulong	FIELD_TYPE;					

typedef ulong 	FUNCTION_TYPE;				
typedef ulong 	INDEX_TYPE;

typedef ulong 	IMPORTER_TYPE;
typedef ulong 	EXPORTER_TYPE;
typedef ulong 	PROGRAM_LANGUAGE_TYPE;
typedef ulong 	COMPRESSOR_TYPE;
typedef ulong 	ENCRYPTION_TYPE;
typedef uchar   LOCK_TYPE;
typedef uchar   DUMP_TYPE;
typedef uchar	JOIN_TYPE;

typedef ulong	TMETHOD_LANGUAGE;


/**********************************************************************************************/
/// This type is used in the CreateTable(). 
/// Specifies how the Table should store its fields: 
///		* as separate columns;
/// 	* as single file with the fixed size records;
//
typedef ulong TableStructure;


/**********************************************************************************************/
// Specify link type, e.g. [1 : 1] [1 : M] [1 : N]  
// 0 - Many
// 1 - One
// N - not more than N, similiar to Many with the top limit.
//
typedef ushort	LinkType;	


/**********************************************************************************************/
// Specifies the length of string:
//
typedef long tslen;


/**********************************************************************************************/
// Header for storing of a disk file in the BLOB field.
// This header is needed to correctly store ALL info of MacOS files.
//
#ifdef WINDOWS
	#pragma pack(push, 2)
#endif

struct OSFileDescription // sizeof = 88 
{
//	char		mName[64]; 
	ulong		mCreator;
	ulong		mType;
	ulong		mDataForkLength;
	ulong		mResForkLength;
	ushort		mFlags;
	uchar		mReserved[6];
};


#ifdef WINDOWS
	#pragma pack(pop)
#endif


/**********************************************************************************************/
enum EStringImpType
{
	kICUImpl,
	kCustomImpl
};


/**********************************************************************************************/
// Typedef for server object identifier.
typedef unsigned long RemoteID;


/**********************************************************************************************/
FBL_End_Namespace


/**********************************************************************************************/
#endif // _FBL_Types_h









